package com.medicine.manage.block.service.impl;

import com.medicine.manage.block.EncryptUtils;
import com.medicine.manage.block.entity.WeBaseResult;
import com.medicine.manage.block.service.AbstractBlockService;
import com.medicine.manage.block.service.IBlockProcessService;
import com.medicine.manage.block.service.IBlockService;

import com.medicine.manage.domain.Express;
import org.springframework.stereotype.Service;

@Service("blockProcessExpressService")
public class BlockProcessExpressServiceImpl extends AbstractBlockService<Express> implements IBlockProcessService<Express> {

    private final String INSERT_ONE_METHOD = "insertExpress";
    private final String SELECT_ONE_METHOD = "updateExpress";
    private final String UPDATE_METHOD = "selectExpress";

    @Override
    public WeBaseResult insertProcessObj(Express express, Long deptId, Long optionUserId) {
        return this.insertOne(express, deptId, optionUserId, INSERT_ONE_METHOD);
    }

    @Override
    public WeBaseResult selectProcessObj(Long orderId, Long expressId, Long deptId, Long optionUserId) {
        return this.selectOne(orderId, expressId, deptId, optionUserId, SELECT_ONE_METHOD);
    }

    @Override
    public WeBaseResult updateProcessObj(Express express, Long deptId, Long optionUserId) {
        return this.update(express.getOrderId(),  express, deptId, optionUserId, UPDATE_METHOD);
    }

    @Override
    protected String createParam(Express o, Long optionUserId) {
        StringBuffer param = new StringBuffer();
        param.append(o.getOrderId()).append(IBlockService.SEPARATOR)
                .append(o.getId()).append(IBlockService.SEPARATOR)
                .append(o.getImage()==null || o.getImage().equals("") ? "": EncryptUtils.sha256(o.getImage())).append(IBlockService.SEPARATOR)
                .append(o.getExpressCompany()).append(IBlockService.SEPARATOR)
                .append(o.getExpressOrder()).append(IBlockService.SEPARATOR)
                .append(optionUserId);

        return param.toString();
    }
}
